/* jshint esversion: 6 */

import React, { FC } from 'react';
import { NavBar, TabBar } from 'antd-mobile';

import {
    Route,
    useHistory,
    useLocation,
    MemoryRouter,
} from 'react-router-dom';
import {
    AppOutline,
    UserOutline,
    EditSOutline 
} from 'antd-mobile-icons';
import styles from './Main.less';
import MySchedule from "../Oa/work/MySchedule";
import Work from "../Oa/work/Work";
import {PRIVATE_ROUTE} from "../../../route.constants";
import ScheduleAdd from "../Oa/work/ScheduleAdd";
import { createMemoryHistory} from "history";
import UserCheckBoxList from "../Oa/work/UserCheckBoxList";
import ScheduleEdit from "../Oa/work/ScheduleEdit";
import ScheduleView from "../Oa/work/ScheduleView";
import Me from "../Me/Me"
import Profile from "../Me/Profile";
import Settings from "../Me/Settings";
import ScheduleOverview from "../Oa/work/ScheduleOverview";
import UserSchedule from "../Oa/work/UserSchedule";
import UserScheduleDetail from "../Oa/work/UserScheduleDetail";
import NoteMenu from '../Oa/Note/NoteMenu';
import NoteMine from  '../Oa/Note/NoteMine';
import NoteAdd from '../Oa/Note/NoteAdd.js';
import NoteCategory from '../Oa/Note/NoteCategory';
import NoteEdit from '../Oa/Note/NoteEdit';
import MyReport from '../Oa/work/MyReport';
import UserReport from '../Oa/work/UserReport';
import UserReportDetail from '../Oa/work/UserReportDetail';
import UserReportToMe from '../Oa/work/UserReportToMe';
import ReportEdit from '../Oa/work/ReportEdit';
import  ReportAdd from '../Oa/work/ReportAdd';
import UserScheduleToMe from '../Oa/work/UserScheduleToMe';
const Bottom: FC = () => {
    const history = useHistory()
    const location = useLocation()
    const { pathname } = location

    const setRouteActive = (value: string) => {
        history.push(value)
    }

    const tabs = [
        {
            key: '/',
            title: '工作',
            icon: <AppOutline />,
        },
        {
            key:'/note',
            title:'笔记',
            icon:<EditSOutline />,

        },
        {
            key: '/me',
            title: '我',
            icon: <UserOutline />,
        },
    ]

    return (
        <TabBar activeKey={pathname} onChange={value => setRouteActive(value)}>
            {tabs.map(item => (
                <TabBar.Item key={item.key} icon={item.icon} title={item.title} />
            ))}
        </TabBar>
    )
}

export default function Main() {

    return (
        <>
            <MemoryRouter history={createMemoryHistory()} initialEntries={['/']}>

            <div className={styles.app}>
                <div className={styles.top}>
                </div>
                <div className={styles.bottom}>
                    <Bottom />
                </div>
                <div className={styles.body}>
                    <Route exact={true} path='/'>
                        <div style={{height: '90vh'}}>
                            <Work></Work>
                        </div>
                    </Route>
                    <Route exact={true} path={'/main/'+PRIVATE_ROUTE.APP_OA_WORK_SCHEDULE_OVERVIEW}>
                        <div style={{height: '90vh'}}>
                            <ScheduleOverview/>
                        </div>
                    </Route>
                   
                    {/* 用户日程路由 */}
                    <Route exact={true} path={'/main/'+PRIVATE_ROUTE.APP_OA_WORK_SCHEDULE_USER}>
                        <div style={{height: '90vh'}}>
                            <UserSchedule/>
                        </div>
                    </Route>
                    {/* 用户日程detail路由 */}
                    <Route exact={true} path={'/main/'+PRIVATE_ROUTE.APP_OA_WORK_SCHEDULE_USER_DETAIL}>
                         <div style={{height: '90vh'}}>
                            <UserScheduleDetail/>
                        </div>
                    </Route>

                    <Route exact={true} path={'/main/'+PRIVATE_ROUTE.APP_OA_WORK_SCHEDULE_MINE}>
                        <div style={{height: '90vh'}}>
                            <MySchedule/>
                        </div>
                    </Route>
                    <Route exact={true} path={'/main/'+PRIVATE_ROUTE.APP_OA_WORK_SCHEDULE_ADD}>
                        <div style={{height: '90vh'}}>
                            <ScheduleAdd/>
                        </div>
                    </Route>
                    <Route exact={true} path={'/main/'+PRIVATE_ROUTE.APP_OA_WORK_SCHEDULE_EDIT}>
                        <div style={{height: '90vh'}}>
                            <ScheduleEdit/>
                        </div>
                    </Route>
                    <Route exact={true} path={'/main/'+PRIVATE_ROUTE.APP_OA_WORK_SCHEDULE_VIEW}>
                        <div style={{height: '90vh'}}>
                            <ScheduleView/>
                        </div>
                    </Route>
                    <Route exact={true} path={'/main/'+PRIVATE_ROUTE.APP_OA_USER_CHECKBOX_LIST}>
                        <div style={{height: '90vh'}}>
                            <UserCheckBoxList/>
                        </div>
                    </Route>


                    <Route exact={true} path={'/main/'+PRIVATE_ROUTE.APP_OA_WORK_SCHEDULE_USER_TO_ME}>
                        <div style={{height: '90vh'}}>
                            <UserScheduleToMe />
                        </div>
                    </Route>

                    <Route exact={true} path={PRIVATE_ROUTE.ME_PROFILE}>
                        <div style={{height: '90vh'}}>
                            <Profile/>
                        </div>
                    </Route>
                    <Route exact={true} path={PRIVATE_ROUTE.ME_SETTINGS}>
                        <div style={{height: '90vh'}}>
                            <Settings />
                        </div>
                    </Route>
                    <Route exact={true} path='/me'>
                        <div style={{height: '90vh'}}>
                        <Me></Me>
                        </div>
                    </Route>
                    {/* 用户笔记路由 */}
                    <Route exact={true} path='/note'>
                        <div style={{height: '90vh'}}>
                            <NoteMenu />
                        </div>
                    </Route>
                    <Route exact={true} path={'/note/'+PRIVATE_ROUTE.APP_OA_NOTE_ADD}>
                        <div style={{height: '90vh'}}>
                            <NoteAdd />
                        </div>
                    </Route>
                    <Route exact={true} path={'/note/'+PRIVATE_ROUTE.APP_OA_NOTE_MINE}>
                        <div style={{height: '90vh'}}>
                            <NoteMine />
                        </div>
                    </Route>
                    
                    <Route exact={true} path={'/note/'+PRIVATE_ROUTE.APP_OA_NOTE_CATEGORY}>
                        <div style={{height: '90vh'}}>
                            <NoteCategory />
                        </div>
                    </Route>
                    <Route exact={true} path={'/note/'+PRIVATE_ROUTE.APP_OA_NOTE_EDIT}>
                        <div style={{height: '90vh'}}>
                            <NoteEdit />
                        </div>
                    </Route>
                    {/* 用户报告路由 */}
                    <Route exact={true} path={'/main/'+PRIVATE_ROUTE.APP_OA_WORK_REPORT_MINE}>
                        <div style={{height: '90vh'}}>
                            <MyReport />
                        </div>
                    </Route>
                    <Route exact={true} path={'/main/'+PRIVATE_ROUTE.APP_OA_WORK_REPORT_USER}>
                        <div style={{height: '90vh'}}>
                            <UserReport />
                        </div>
                    </Route>
                    <Route exact={true} path={'/main/'+PRIVATE_ROUTE.APP_OA_WORK_REPORT_USER_DETAIL}>
                        <div style={{height: '90vh'}}>
                            <UserReportDetail />
                        </div>
                    </Route>
                    <Route exact={true} path={'/main/'+PRIVATE_ROUTE.APP_OA_WORK_REPORT_USER_TO_ME}>
                        <div style={{height: '90vh'}}>
                            <UserReportToMe />
                        </div>
                    </Route>
                    <Route exact={true} path={'/main/'+PRIVATE_ROUTE.APP_OA_WORK_REPORT_ADD}>
                        <div style={{height: '90vh'}}>
                            <ReportAdd />
                        </div>
                    </Route>
                    <Route exact={true} path={'/main/'+PRIVATE_ROUTE.APP_OA_WORK_REPORT_EDIT}>
                        <div style={{height: '90vh'}}>
                            <ReportEdit />
                        </div>
                    </Route>

                </div>
                
            </div>
            </MemoryRouter>


        </>
    )
}





